package com.yan.demo.loopdemo;

public class ForDemo2 {
    public static void main(String[] args) {
        int sum = 0;
        System.out.println("奇数");
        for (int i = 0 ; i <= 100 ; i++){
            if(i % 2 == 1 ){
                System.out.print(i + " ");
            }
            sum += i;
        }
        System.out.println("sum = " + sum);
        System.out.println();
        System.out.println("偶数");
        sum = 0;
        for (int i = 0 ; i <= 100 ; i++){
            if(i % 2 == 0 ){
                System.out.print(i + " ");
            }
            sum += i;
        }
        System.out.println("sum = " + sum);

    }
}
